<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="GNU source-highlight 1.6.3
by Lorenzo Bettini, bettini@gnu.org
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite">
<title>code/Ch2/mail/MailSystemTest.java</title>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#0000EE" vlink="#551A8B" alink="#FF0000">
<pre>
<tt>
01: <b><font color=#000080>import</font></b> java<font color=#990000>.</font>io<font color=#990000>.</font>BufferedReader<font color=#990000>;</font>
02: <b><font color=#000080>import</font></b> java<font color=#990000>.</font>io<font color=#990000>.</font>InputStreamReader<font color=#990000>;</font>
03: <b><font color=#000080>import</font></b> java<font color=#990000>.</font>io<font color=#990000>.</font>IOException<font color=#990000>;</font>
04: 
05: <i><font color=#9A1900>/**</font></i>
06: <i><font color=#9A1900>   This program tests the mail system. A single phone</font></i>
07: <i><font color=#9A1900>   communicates with the program through System.in/System.out.</font></i>
08: <i><font color=#9A1900>*/</font></i>
09: <b><font color=#0000FF>public</font></b> <b><font color=#0000FF>class</font></b> MailSystemTest
10: <font color=#FF0000>{</font>
11:    <b><font color=#0000FF>public</font></b> <b><font color=#0000FF>static</font></b> <font color=#009900>void</font> <b><font color=#000000>main</font></b><font color=#990000>(</font>String<font color=#990000>[</font><font color=#990000>]</font> args<font color=#990000>)</font> <b><font color=#0000FF>throws</font></b> IOException
12:    <font color=#FF0000>{</font>
13:       MailSystem system <font color=#990000>=</font> <b><font color=#0000FF>new</font></b> <b><font color=#000000>MailSystem</font></b><font color=#990000>(</font>MAILBOX_COUNT<font color=#990000>)</font><font color=#990000>;</font>
14:       BufferedReader console <font color=#990000>=</font> <b><font color=#0000FF>new</font></b> <b><font color=#000000>BufferedReader</font></b><font color=#990000>(</font>
15:          <b><font color=#0000FF>new</font></b> <b><font color=#000000>InputStreamReader</font></b><font color=#990000>(</font>System<font color=#990000>.</font>in<font color=#990000>)</font><font color=#990000>)</font><font color=#990000>;</font>
16: 
17:       Telephone p <font color=#990000>=</font> <b><font color=#0000FF>new</font></b> <b><font color=#000000>Telephone</font></b><font color=#990000>(</font>console<font color=#990000>)</font><font color=#990000>;</font>
18:       Connection c <font color=#990000>=</font> <b><font color=#0000FF>new</font></b> <b><font color=#000000>Connection</font></b><font color=#990000>(</font>system<font color=#990000>,</font> p<font color=#990000>)</font><font color=#990000>;</font>
19:       p<font color=#990000>.</font><b><font color=#000000>run</font></b><font color=#990000>(</font>c<font color=#990000>)</font><font color=#990000>;</font>
20:    <font color=#FF0000>}</font>
21: 
22:    <b><font color=#0000FF>private</font></b> <b><font color=#0000FF>static</font></b> <b><font color=#0000FF>final</font></b> <font color=#009900>int</font> MAILBOX_COUNT <font color=#990000>=</font> <font color=#993399>20</font><font color=#990000>;</font>
23: <font color=#FF0000>}</font>
</tt>
</pre>
</body>
</html>
